//
//  HouseDetailViewController.swift
//  777Proj
//
//  Created by 陈宇 on 2017/5/8.
//  Copyright © 2017年 🐜. All rights reserved.
//

import UIKit
import GoogleMaps
import FSPagerView
import Haneke

class HouseDetailViewController: BaseViewController {
    
    @IBOutlet weak var bannerView: FSPagerView! {
        didSet {
            self.bannerView.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
        }
    }
    @IBOutlet weak var scrollView: UIScrollView!
    @IBOutlet weak var avatarView: UIImageView!
    @IBOutlet weak var btn_favorite: UIButton!
    @IBOutlet weak var btn_edit: UIButton!
    @IBOutlet weak var btn_bid: UIButton!
    @IBOutlet weak var mapView: GMSMapView!
    
    override func configureUI() {
        super.configureUI()
        
        title = "Detail"
        
        let 是竞标房源 = true
        
        if 是竞标房源 {
            scrollView.contentInset = UIEdgeInsetsMake(0, 0, 49, 0)
            scrollView.scrollIndicatorInsets = scrollView.contentInset
        }
        
        avatarView.hnk_setImageFromURL(APP.APP_PLACEHOLDER_URL)
    }
    
    override func configureEvent() {
        super.configureEvent()
        
        btn_favorite.rx.tap.bind {
            UIApplication.whisper(title: "添加到喜欢".localized())
            }.addDisposableTo(disposeBag)
        
        btn_edit.rx.tap.bind {
            UIApplication.whisper(title: "编辑".localized())
            }.addDisposableTo(disposeBag)
        
        btn_bid.rx.tap.bind {
            UIApplication.whisper(title: "参与竞标".localized())
            }.addDisposableTo(disposeBag)
    }
    
}

extension HouseDetailViewController: GMSMapViewDelegate {
    
}

extension HouseDetailViewController: FSPagerViewDataSource, FSPagerViewDelegate {
    
    func numberOfItems(in pagerView: FSPagerView) -> Int {
        return 3
    }
    
    func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
        
        let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index)
        cell.imageView?.hnk_setImageFromURL(APP.APP_PLACEHOLDER_URL, format: Format(name: "cell"))
        return cell
    }
    
}
